package com.xinzhi.controller;

import com.xinzhi.entity.Video;
import com.xinzhi.service.VideoService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin(origins = "http://localhost:8080")
@RestController
@RequestMapping("/videos")
public class Videocontroller {
    @Autowired
    private VideoService vis;

    @GetMapping("/head")
    public Result firstvideo(Integer id) {
        System.out.println(id);
        Video first = vis.selVideo(id);
        return Result.videosuccess(first);
    }

    @PostMapping("/selall")
    public Result sel() {
        List<Video> videos = vis.getvideo();
        return Result.videosuccess(videos); // 确保服务层方法的名称正确
    }
}
